import os

import allure
from selenium.webdriver.common.by import By
from web_ui_item.pageobject.base_page import BasePage
from web_ui_item.pageobject.management_page import ManagementPage
from web_ui_item.utils.logger import logger
from web_ui_item.utils.read_data import r_data

BASE_PATH = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
ELE_PATH = os.path.join(BASE_PATH, "data/elements.yaml")

class MainPage(BasePage):

    _page = r_data.load_yaml(ELE_PATH)["main_page"]

    def goto_message(self):
        pass

    def goto_calendar(self):
        pass

    def goto_management(self):
        '''
        点击后台管理按钮
        :return:
        '''
        with allure.step("打开后台管理页面"):
            self.find(By.CSS_SELECTOR, self._page["menu"]).click()
            self.find(By.CSS_SELECTOR, self._page["manage_btn"]).click()
        logger.debug("跳转到后台管理页面")
        return ManagementPage(self.driver)
